<!-- 财务人员界面(除) -->
<template>
	<div>
		<el-table :data="tableData" style="width: 100%;">
			<el-table-column type="selection" width="55">
			</el-table-column>
			<el-table-column fixed label="项目ID" prop="id" sortable width="100"></el-table-column>
			<el-table-column label="项目内容" prop="trainingContent" sortable width="100"></el-table-column>
			<el-table-column label="项目时间" prop="trainingTime" sortable width="100"></el-table-column>
			<el-table-column label="项目资金" prop="trainingCost" sortable width="100"></el-table-column>
			<el-table-column label="操作" sortable width="100">
				<template slot-scope="scope">
					<el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">参加</el-button>
				</template>
			</el-table-column>
			
		</el-table>
		<el-pagination :current-page="pageInfo.currentPage" :page-size="pageInfo.pageSize" :page-sizes="[3, 5, 10, 50]"
			:total="pageInfo.total" layout="total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange"
			@current-change="handleCurrentChange">
		</el-pagination>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					id: "",
					base: "",
					bonus: ""
				},
				dialogFormVisible: false,
				formLabelWidth: "70px",
				tableData: [],
				pageInfo: {
					total: 10,
					currentPage: 1,
					pageNum: 1,
					pageSize: 10
				},
			}
		},
		mounted() {
			this.findArtList(1, this.pageInfo.pageSize);
		},
		methods: {
			handleDelete(index, row) {
				var id = row.id;
				this.$confirm('您确定要参加吗?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.$http.get("/finance/updateState/"+id).then(res => {
						if(res.data.code == 200){
						this.$message({
							message: '参加成功',
							type: 'success'
						})
						}else{
							this.$message({
								message: '参加失败',
								type: 'danger'
							})
						}
						this.findArtList(this.pageInfo.pageNum, this.pageInfo.pageSize);
					})
				})
			},
			findArtList(page, limit) {
				var id = window.sessionStorage.getItem("userId");
				var that = this;
				that.$http.post("/finance/selAttend/" + page + "/" + limit+"/"+id).then(function(res) {
					if (res.data.code != "500") {
						that.tableData = res.data.data;
						//that.tableData1 = res.data.dataa;
						console.log(res.data.data)
						that.total = res.data.total;
						that.pageInfo.total = res.data.total;
					}
				})
			},
			handleSizeChange(val) {
				this.pageInfo.pageSize = val;
				this.findArtList(this.pageInfo.pageNum, this.pageInfo.pageSize);
			},
			handleCurrentChange(val) {
				this.pageInfo.pageNum = val;
				this.findArtList(this.pageInfo.pageNum, this.pageInfo.pageSize);
			}
		}
	}
</script>
<style>
	.w {
		text-align: left;
	}
</style>
